<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>智能农业系统</title>
    <script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script>
    <script src="./js/mqtt.js"></script>
    <style>
        body {
            height: 100%;
            margin: 0;
            padding: 0;
            background: url('./img/bg.jpg') no-repeat;
            background-size: cover;
            background-position: center center;

        }

        .parent_box {
            display: flex;
            /* 使用 Flexbox 布局 */
            justify-content: center;
            /* 水平居中对齐 */
            align-items: center;
            /* 垂直居中对齐 */
            width: 100vw;
            /* 父容器宽度为视口宽度 */
            height: 100vh;
            /* 父容器高度为视口高度 */
        }

        .container_box {
            width: 85%;
            height: 75%;
            background-color: #00000060;
            text-align: center;
            border-radius: 10px;
            padding: 50px 50px;
            border: solid 3px #ffffffff;
            color: #fff;
        }

        .item_box {
            position: relative;
            margin-top: 10px;
            width: 100%;
            height: 80%;
            background-color: rgba(255, 255, 255, 0);
            text-align: center;
            border-radius: 10px;
            border: 2px solid white;

        }

        .tag_box {
            position: relative;
            /* 水平平均分布 */
            display: flex;
            justify-content: space-between;
            /* 垂直居中 */
            align-items: center;
            margin-top: 1%;
            /* 水平居中 */
            margin-left: auto;
            margin-right: auto;
            width: 90%;
            height: 10%;
            /* border: 1px solid black; */
        }

        .content_box {
            position: relative;
            display: flex;
            justify-content: space-between;
            margin-top: 1%;
            width: 100%;
            max-height: 80%;
            /* border: 1px solid red; */
            /* padding: 10px 0; */
        }

        .data_box {
            margin: 1%;
            width: 30%;
            height: 80%;
            border-radius: 5px;
            border: 2px solid white;
        }


        .previous_btn {
            /* 设置背景图片 */
            /* background-color: transparent; */
            background-image: url("./img/previous_btn.png");
            /* 设置背景大小 */
            background-size: cover;
            background-color: rgba(0, 0, 0, 0);
            /* 设置按钮宽高 */
            /* 设置透明度为0 */
            /* opacity: 0; */
            width: 16px;
            height: 16px;

            /* border: none;
            outline: none; */
        }

        .previous_btn .clicked {
            /* 设置点击时的背景图片 */
            background-image: url("./img/previous_btn_clicked.png");
        }

        .next_btn {
            /* 设置背景图片 */
            /* background-color: transparent; */
            background-image: url("./img/next_btn.png");
            /* 设置背景大小 */
            background-size: cover;
            background-color: rgba(0, 0, 0, 0);
            /* 设置按钮宽高 */
            /* 设置透明度为0 */
            width: 16px;
            height: 16px;

            /* border: none;
            outline: none; */
        }

        .next_btn .clicked {
            /* 设置点击时的背景图片 */
            background-image: url("./img/next_btn_clicked.png");
        }

        /* 水平标签栏 */
        ul {
            list-style-type: none;
            margin: 0;
            padding: 0;
            overflow: hidden;
            border: 1px solid #e7e7e7;
            background-color: #f3f3f3;
        }

        li {
            float: left;
        }

        li a {
            display: block;
            color: #666;
            text-align: center;
            padding: 14px 16px;
            text-decoration: none;
        }

        li a:hover:not(.active) {
            background-color: #ddd;
        }

        li a.active {
            color: white;
            background-color: #4CAF50;
        }

        /* 表单 */
        form {
            margin-top: 10px;
            /* 水平平均分布 */
            display: flex;
            justify-content: space-between;
        }

        /* 表格 */
        table {
            margin: auto;
        }

        table th {
            height: 30px;
        }

        table td {
            padding: 10px 0;
            width: 150px;
            color: #4CAF50;
        }

        /* 输入 */
        input {
            width: 100px;
        }

        input[type="text"] {
            text-align: center;
            width: 50px;
            height: 20px;
        }

        input[type="button"] {
            width: 70px;
            height: 30px;
        }
    </style>
</head>

<body onload="load_func();">
    <div class="parent_box">
        <div class="container_box">
            <ul>
                <li><a class="active" href="#home">Home</a></li>
                <li><a href="#news">News</a></li>
                <li><a href="#contact">Contact</a></li>
                <li><a href="#about">About</a></li>
            </ul>
            <form>
                <div id="user_div">
                    用户：<input type="text" id="user">
                </div>
                <div id="card_div">
                    卡号：<input type="text" id="card">
                </div>
                <div id="date_div">
                    日期:<select id="year_select" onchange="set_select_data();">
                        <option value=""></option>
                        <option value="2020">2020</option>
                        <option value="2021">2021</option>
                        <option value="2022">2022</option>
                        <option value="2023">2023</option>
                        <option value="2024">2024</option>
                    </select>年
                    <select id="month_select" onchange="set_select_data();">
                        <option value=""></option>
                        <option value="01">1</option>
                        <option value="02">2</option>
                        <option value="03">3</option>
                        <option value="04">4</option>
                        <option value="05">5</option>
                        <option value="06">6</option>
                        <option value="07">7</option>
                        <option value="08">8</option>
                        <option value="09">9</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                        <option value="12">12</option>
                    </select>月
                    <select id="day_select">
                    </select>日
                </div>
                <input type="checkbox" id="is_like_checkbox" value="is_like">模糊查找
                <input type="button" value="查询" onclick="up_data();">
                <input type="reset" value="重置">
                <input type="button" id="delete" value="删除" onclick="delete_btn();">
                <input type="button" id="update" value="修改" onclick="update_btn();">
                <input type="button" id="get_card_btn" value="获取卡号" onclick="get_card();">
                <br>
            </form>

            <div class="item_box">
                <div class="tag_box">
                    <input type="button" value="历史数据" id="history_data_btn">
                    <label id="connect_status">等待连接...</label>
                    <label id="time_now"></label>
                    <input type="button" value="下发" id="setting" onclick="setting_btn()">
                </div>
                <div class="content_box">
                    <!-- 阈值 -->
                    <div class="data_box">
                        <table>
                            <tr>
                                <th>最小值</th>
                                <th>最大值</th>
                                <th>单位</th>
                            </tr>
                            <tr>
                                <td>
                                    <input type="text" id="min_temp" value="0">
                                </td>
                                <td>
                                    <input type="text" id="max_temp" value="0">
                                </td>
                                <td>
                                    ℃
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <input type="text" id="min_humi" value="0">
                                </td>
                                <td>
                                    <input type="text" id="max_humi" value="0">
                                </td>
                                <td>
                                    %
                                </td>
                            </tr>
                        </table>
                    </div>
                    <!-- 当前值 -->
                    <div class="data_box">
                        <table>
                            <tr>
                                <th>传感器</th>
                                <th>当前值</th>
                            </tr>
                            <tr>
                                <td>
                                    <label>温度：</label>
                                </td>
                                <td>
                                    <label id="temp_val">0</label>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label>湿度：</label>
                                </td>
                                <td>
                                    <label id="humi_val">0</label>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <!-- 状态 -->
                    <div class="data_box">
                        <table>
                            <tr>
                                <th>控制节点</th>
                                <th>当前状态</th>
                                <th>当前模式</th>
                            </tr>
                            <tr>
                                <td>
                                    <label>排风扇：</label>
                                </td>
                                <td>
                                    <input type="button" id="fan_status" value="close" onclick="fan_status_btn()">
                                </td>
                                <td>
                                    <input type="button" id="fan_mode" value="manual" onclick="fan_mode_btn()">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label>滴灌：</label>
                                </td>
                                <td>
                                    <input type="button" id="drip_status" value="close" onclick="drip_status_btn()">
                                </td>
                                <td>
                                    <input type="button" id="drip_mode" value="manual" onclick="drip_mode_btn()">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label>卷帘：</label>
                                </td>
                                <td>
                                    <input type="button" id="roller_shutter_status" value="close"
                                        onclick="roller_shutter_status_btn()">
                                </td>
                                <td>
                                    <input type="button" id="roller_shutter_mode" value="manual"
                                        onclick="roller_shutter_mode_btn()">
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>

            <!-- <table id="table" border="1px" align="center">
                <tr>
                    <th width='120' height='50' align='center'>用户</th>
                    <th width='120' height='50' align='center'>卡号</th>
                    <th width='120' height='50' align='center'>日期</th>
                    <th width='120' height='50' align='center'>上班打卡时间</th>
                    <th width='120' height='50' align='center'>上班打卡状态</th>
                    <th width='120' height='50' align='center'>下班打卡时间</th>
                    <th width='120' height='50' align='center'>下班打卡状态</th>
                </tr>
            </table> -->

            <!-- <div id="pagination-container">
                <button class="previous_btn" onclick="previousPage()"></button>
                <label id="page_num">1</label>
                <button class="next_btn" onclick="nextPage()"></button>
            </div> -->
        </div>
    </div>
</body>

</html>